<?php
echo isset($header) ? $header : '';
?>

<script type="text/javascript" src="/js/client_many.js"></script>

<div id="content">
    <div class="form_style">

        <div class="title" style="font-size: 20px;padding: 10px 1px 0px 18px;">
            <a href="#" class="client" >客戶</a>｜
            <a href="#" class="contact" >聯絡人</a>｜
            <a href="#" class="relationship" >關係人</a>			
        </div>

        <div id="client_info">
			<?php
			if(0){ 
			?>
            <form method="post" action="<?= site_url('/client/data_entry_submit') ?>" id="userinfo" >
			<?php
			}			
			?>
			<!------------------------------------------------------->
			<?php
			if(1){ 
			?>
            <form method="post" action="<?= site_url('/client/data_entry_submit') ?>" id="userinfo" >
			<?php
			}			
			?>
                <input type="hidden" name="ref_client_verify_code" value="<?= $ref_client_verify_code ?>" >

                <!--表单从这里开始-->
                <table >
                    <tbody><tr>
                            <th style="width:65px;" id="w1" class="must_write">客戶姓名</th>
                            <td>
                                <input type="text" style="width:138px;"  name="name" id="name" style="vertical-align:middle;">
                                <img style="cursor: pointer; vertical-align:middle;" onclick="check_client_name()" src="/images/search.png" alt="" width="16px">
                                <span status="false" class="error" id="unique_info"></span>
                                <div id="search_user_div"></div>
                            </td>
                            <th style="width:65px;" id="w2">特徴</th>
                            <td>
                                <input type="text" id="recommended" name="recommended" >
                            </td>
                            <th style="width:65px;" id="w3">重要性</th>
                            <td>
                                <select class="full_select" id="importance" name="importance">
                                    <option value="">&nbsp;</option>
                                    <?
                                    foreach($importance_of_customers as $key=>$val){
                                    ?>
                                    <option value="<?= $val->value ?>"><?= $val->value ?></option>
                                    <?
                                    }
                                    ?>
                                </select>
                            </td>
                            <th style="width:65px;" id="w4">國籍</th>
                            <td>
                                <select id="nationality" name="nationality"  class="full_select">
                                    <?
                                    foreach($nationality as $key=>$val){
                                    ?>
                                    <option value="<?= $val->nationality_id ?>"><?= $val->value ?></option>
                                    <?
                                    }
                                    ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>英文姓名</th>
                            <td><input type="text"  id="english_name" name="english_name" style="width:138px;"></td>
                            <th>性別</th>
                            <td>
                                <input type="radio" value="1" id="sex" name="sex">男&nbsp;&nbsp;<input type="radio" value="0" id="sex" name="sex">女
                            </td>
                            <th>客戶來源</th>
                            <td>
                                <select class="full_select" id="customer_source" name="customer_source">
                                    <option value="">&nbsp;</option>
                                    <?
                                    foreach($customer_source as $key=>$val){
                                    ?>
                                    <option value="<?= $val->customer_source_id ?>"><?= $val->value ?></option>
                                    <?
                                    }
                                    ?>
                                </select>
                            </td>

                            <th>備註其他</th>
                            <td><input type="button" onclick="detail_info();" value="詳細訊息" class="input_background"></td>
                        </tr>

                        <tr>
                            <th>行動電話</th>
                            <td colspan="3">
                                <ul id="add_tel">
                                    <li name="mobile_li">
                                        <input type="text" class="mobile" id="mobile" name="mobile" style="width:260px;"> <a onclick="add_mobile()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                    </li>
                                </ul>
                            </td>
                            <th>簡訊發送</th>
                            <td colspan="5">
                                <ul id="mobilesms">
                                    <li>
                                        <input type="radio" checked="" value="Y" id="send_sms" name="send_sms" >Y&nbsp;
                                        <input type="radio" value="N" id="send_sms" name="send_sms">N</li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>住家電話</th>
                            <td colspan="7">
                                <ul id="home_tel">
                                    <li>
                                        <input type="text" class="colspan_input1" id="home_phone" name="home_phone" style="width:260px;"> <a onclick="add_home_phone()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                    </li>
                                </ul>
                            </td>

                        </tr>
                        <tr>
                            <th>公司電話</th>
                            <td colspan="7">
                                <ul id="company_tel">
                                    <li>
                                        <input type="text" class="colspan_input1" id="company_phone" name="company_phone" style="width:260px;">&nbsp;&nbsp;<b>分機</b>&nbsp;&nbsp;<input type="text" class="c_tel_2" id="company_phone_ext" name="company_phone_ext">&nbsp;<a onclick="add_company_phone()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>		    			
                                    </li>
                                </ul>	
                            </td>
                        </tr>
                        <tr>
                            <th>電子郵件</th>
                            <td colspan="3">
                                <ul id="email0">
                                    <li>
                                        <input type="text" id="email" name="email" class="email_input" onblur="checkemail('email')"><input type="button" onclick="open_email('email');" value="開啟mail" class="input_background"><a onclick="add_email();" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>	
                                    </li>
                                </ul>
                            </td>
                            <th>寄發EDM</th>
                            <td colspan="5">
                                <ul id="email_edm">
                                    <li >
                                        <input type="radio" checked="" value="Y" id="send_email" name="send_email">Y&nbsp;&nbsp;<input type="radio" value="N" id="send_email" name="send_email">N
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>傳真電話</th>
                            <td colspan="7">
                                <ul id="fax_u">
                                    <li>
                                        <input type="text" class="colspan_input1" id="fax" name="fax" style="width:260px;"> <a onclick="add_fax();" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>住家地址</th>
                            <td colspan="3">
                                <ul id="home_addr">
                                    <li>
                                        <input type="text" onclick="show_address('home_address');" class="colspan_input" id="home_address" name="home_address">
                                        <a onclick="add_home_address();" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                    </li>
                                </ul>
                            </td>
                            <th>住家－大樓名稱</th>
                            <td>
                                <ul id="building_name">
                                    <li>
                                        <input id="home_building_name" name="home_building_name" size="50" style="width:148px;"  />
                                    </li>
                                </ul>
                            </td>
                            <th>寄發刊物</th>
                            <td colspan="3">
                                <ul id="per">
                                    <li>
                                        <input type="radio" checked="checked" value="Y" id="home_send_publication" name="home_send_publication">Y&nbsp;&nbsp;<input type="radio" value="N" id="home_send_publication" name="home_send_publication">N
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>公司名稱</th>
                            <td colspan="3">
                                <ul id="company_name0">
                                    <li>
                                        <input type="text" class="colspan_input" id="company_name" name="company_name"> 
                                        <a onclick="add_company();" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                        <div id="showco"></div>
                                    </li>
                                </ul>
                            </td>
                            <th>公司類型</th>
                            <td>
                                <ul id="company_type">
                                    <li>
                                        <select class="full_select" id="type_of_company" name="type_of_company" style="width:auto;">
                                            <?
                                            foreach($type_of_company as $key=>$val){
                                            ?>
                                            <option value="<?= $val->type_of_company_id ?>"><?= $val->value ?></option>
                                            <?
                                            }
                                            ?>
                                        </select>
                                    </li>
                                </ul>
                            </td>
                            <th>統一編號</th>
                            <td colspan="3">
                                <ul id="company_id">
                                    <li>
                                        <input type="text" style="width:160px;" onblur="checkunicode();" name="unicode" id="unicode"><span class="error" id="uniformcode"></span>
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>部門</th>
                            <td>
                                <ul id="dept">
                                    <li> <input type="text" id="department" name="department"> </li>
                                </ul>
                            </td>
                            <th>職稱</th>
                            <td colspan="3">
                                <ul id="zhichen">
                                    <li>
                                        <select  class="full_select" id="title" name="title" style="width:auto;">
                                            <option value=""> </option>
                                            <?
                                            foreach($title as $key=>$val){
                                            ?>
                                            <option value="<?= $val->title_id ?>"><?= $val->value ?></option>
                                            <?
                                            }
                                            ?>
                                        </select>
                                    </li>
                                </ul>
                            </td>
                            <th>類別</th>
                            <td>
                                <ul id="company_type2">
                                    <li>
                                        <input id="category" name="category" size="50" style="width:160px;"  />
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>公司地址</th>
                            <td colspan="3">
                                <ul id="company_addr">
                                    <li><input type="text" id="company_address" class="large_input" name="company_address" onclick="show_address('company_address');" style="width:373px;"></li>
                                </ul>
                            </td>
                            <th>公司－大樓名稱</th>
                            <td>
                                <ul id="building_company_name">
                                    <li>
                                        <input id="company_building_name" name="company_building_name" size="50" style="width:148px;"  />
                                    </li>
                                </ul>
                            </td>
                            <th>寄發刊物</th>
                            <td colspan="3">
                                <ul id="per_com">
                                    <li><input type="radio" checked="" value="Y" id="company_send_publication" name="company_send_publication">Y&nbsp;&nbsp;<input type="radio" value="N" id="company_send_publication" name="company_send_publication">N</li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <th>公司網址</th>
                            <td colspan="7">
                                <ul id="company_website0">
                                    <li>
                                        <input type="text" id="company_website" style="width:374px;" name="company_website"><input type="button" onclick="open_website('company_website');" value="開啟IE" class="input_background">
                                    </li>
                                </ul>
                            </td>
                        </tr>
                        
                        
                        <tr>
                            <th>機密等級</th>
                            <td>
                                <select name="sercet_level" id="sercet_level"  >	
									<option value="1" >普通</option>						
									<option value="3" >極機密</option>
									<option value="2" >機密</option>														
								</select>
                            </td>

                            <th>是否公開</th>
                            <td>
                                
                                <select name="is_public" id="is_public"  >														
									<option value="1" >公開</option>
									<option value="2" >不公開</option>							
								</select>	    		
                            </td>

                            <th>重要性</th>
                            <td>
                            	<select name="important" id="important" >
									<option value="1"  >普通</option>								
									<option value="3"  >極重要</option>
									<option value="2"  >重要</option>												
								</select>
                            </td>

                            <th style="display:none;">遮蔽欄位</th>
                            <td style="display:none;">
                               <select name="is_see" id="is_see" >														
									<option value="2" >遮蔽</option>
									<option value="1" >不遮蔽</option>							
								</select>
                            </td>
                        </tr>			  

                        <tr>
                            <th>接待人</th>
                            <td>
                                <?php
                                $th = $this->session->all_userdata();
                                ?>
                                <input type="hidden" value="<?= $th["users_id"] ?>" id="front_man" name="front_man" >
                                <?= $th["user"] ?>
                            </td>

                            <th>主管</th>
                            <td>
                                <input type="hidden" id="head" name="head" value="<?= $head[0]->users_id ?>">
                                <?= $head[0]->name ?>		    		
                            </td>

                            <th>原經紀人</th>
                            <td></td>

                            <th>經紀人</th>
                            <td>
                                <input type="hidden" value="<?= $th["users_id"] ?>" id="broker" name="broker" >
                                <?= $th["user"] ?>
                            </td>
                        </tr>
                        
                        
                        





                    </tbody>
                </table>
                <!-- 表单在这里结束 -->
                <div id="detail_info" style="display: none;">
                    <table>
                        <tbody><tr>
                                <th width="80" class="utitle">生日</th>
                                <td width="110"><input type="text" class="Wdate" onclick="WdatePicker()" id="birthday" name="birthday"></td>
                                <th width="70" class="utitle">送禮</th>
                                <td><input type="radio" value="Y" id="gifts" name="gifts">Y&nbsp;&nbsp;<input type="radio" value="N" id="gifts" name="gifts" checked="checked">N</td>
                            </tr>
                            <tr>
                                <th class="utitle">身分證字號</th>
                                <td colspan="3"><input type="text" style="width:95px;" name="id_number" id="id_number" onblur="checkidnumber();">
                                    <span class="error" id="carderrorinfo"></span></td>
                            </tr>
                            <tr>
                                <th class="utitle">平常連絡</th>
                                <td colspan="3">
                                    <ul id="ping">
                                        <li class="ping_li">
                                            <select style="width:70px;" id="usually_contact" name="usually_contact">
                                                <option value=""></option>
                                                <?
                                                foreach($contact_usual_holiday as $key=>$val){
                                                ?>
                                                <option value="<?= $val->contact_usual_holiday_id ?>"><?= $val->value ?></option>
                                                <?
                                                }
                                                ?>
                                            </select>
                                            &nbsp;&nbsp;&nbsp;
                                            起&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="usually_start_time" name="usually_start_time">&nbsp;&nbsp;&nbsp;
                                            止&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="usually_end_time" name="usually_end_time">
                                            <a onclick="add_usually_contact()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                        </li>
                                    </ul>				    	
                                </td>
                            </tr>
                            <tr>
                                <th class="utitle">假日連絡</th>
                                <td colspan="3">
                                    <ul id="holiday">
                                        <li class="holiday_li">
                                            <select id="holidays_contact" style="width:70px;" name="holidays_contact">
                                                <option value=""></option>
                                                <?
                                                foreach($contact_usual_holiday as $key=>$val){
                                                ?>
                                                <option value="<?= $val->contact_usual_holiday_id ?>"><?= $val->value ?></option>
                                                <?
                                                }
                                                ?>
                                            </select>&nbsp;&nbsp;&nbsp;&nbsp;
                                            起&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="holidays_start_time" name="holidays_start_time">&nbsp;&nbsp;&nbsp;
                                            止&nbsp;<input type="text" style="width:70px;" class="Wdate" onfocus="WdatePicker({dateFmt: 'HH:mm'})" id="holidays_end_time" name="holidays_end_time">
                                            <a onclick="add_holidays_contact()" class="additem"><i class="icon-plus">&nbsp;&nbsp;</i></a>
                                        </li>
                                    </ul>
                                </td>			    
                            </tr>
                            <tr>
                                <th class="utitle">背景與特色</th>
                                <td class="cu_charac" colspan="3"><textarea id="background_and_features" name="background_and_features" class="utextarea"></textarea></td>
                            </tr>
                            <tr>
                                <td align="center" colspan="4">
                                    <input type="button" onclick="detail_info_determine();" value="確定" class="input_background">
                                </td>
                            </tr>
                        </tbody></table>
                </div>


                <?php
                $this->load->view("showbox/address");
                ?>
            </form>

        </div>


        <div id="contact_info" style="display: none;">
            <div id="client_info">
                <input type="button" class="btn" value="增加聯絡人" OnClick="add_contact();">
                <?php
                $i = 0;
                ?>

                <form  id="contact_info" >

                    <input type="hidden" name="ref_client_verify_code" value="<?= $ref_client_verify_code; ?>">

                    <table id="contact_count" style="margin: 10px;">

                        <tr id="w1">
                            <th style="width:65px;" id="w3" class="must_write">客戶姓名</th>
                            <td>
                                <input type="text" style="width:138px;"  name="contact[<?= $i ?>][name]" id="c_name" style="vertical-align:middle;">

                            </td>

                            <th style="width:65px;" id="w3">英文姓名</th>
                            <td>
                                <input type="text" id="recommended" name="contact[<?= $i ?>][english_name]" >
                            </td>

                            <th style="width:65px;" id="sex" id="w3">
                                性別
                            </th>

                            <td colspan="3">
                                男
                                <input type="radio" name="contact[<?= $i ?>][sex]" value='1' checked="true">
                                女
                                <input type="radio" name="contact[<?= $i ?>][sex]" value='0'>
                            </td>

                        </tr>


                        <tr id="w2">
                            <th style="width:65px;" id="w2">行動電話</th>
                            <td>
                                <input type="text" name="contact[<?= $i ?>][mobile]" >
                            </td>

                            <th style="width:65px;" id="w2">住家電話</th>
                            <td>
                                <input type="text" name="contact[<?= $i ?>][home_phone]" >
                            </td>

                            <th style="width:65px;" id="w2">公司電話</th>
                            <td>
                                <input type="text" name="contact[<?= $i ?>][company_phone]" >
                            </td>

                            <th style="width:65px;" id="w2">傳真</th>
                            <td>
                                <input type="text" name="contact[<?= $i ?>][fax]" >
                            </td>
                        </tr>    

                        <tr id="w1">                            
                            <th style="width:65px;" id="w3">住家地址</th>
                            <td colspan="3">
                                <input type="text" name="contact[<?= $i ?>][home_address]"   id="contact_home_address_<?= $i ?>" style="width: 300px;"  onClick="show_address('contact_home_address_<?= $i ?>')" >
                            </td>

                            <th style="width:65px;" id="w3">公司地址</th>
                            <td colspan="3">
                                <input type="text" name="contact[<?= $i ?>][company_address]"   id="contact_company_address_<?= $i ?>" style="width: 300px;"  onClick="show_address('contact_company_address_<?= $i ?>')" >
                            </td>
                        </tr>    

                    </table>


                    <div id="html_contact">                	
                    </div>




                </form>	
            </div>
        </div>	



        <style>
            .btn {
                background-color: #ccc;
                -moz-border-radius: 5px;
                -webkit-border-radius: 5px;
                border-radius: 6px;
                color: #000;
                font-family: 'Oswald';
                font-size: 20px;
                text-decoration: none;
                cursor: pointer;
                border: none;
            }

            #relationship_info table th {
                background: #e9e9e9;
                color: #666666;
                padding: 4px 8px;
                text-align: left;
                white-space: nowrap;
                height: 32px;
                line-height: 32px;
                padding: 10px;
            }

            #relationship_info table tr {
                background: none repeat scroll 0 0 transparent;
                border: 0 none;
                font-size: 100%;
                margin: 0;
                outline: 0 none;
                padding: 0;
                vertical-align: baseline;
            }

            #contact_info table th {
                background: #e9e9e9;
                color: #666666;
                padding: 4px 8px;
                text-align: left;
                white-space: nowrap;
                height: 32px;
                line-height: 32px;
                padding: 10px;
            }

            #contact_info table tr {
                background: none repeat scroll 0 0 transparent;
                border: 0 none;
                font-size: 100%;
                margin: 0;
                outline: 0 none;
                padding: 0;
                vertical-align: baseline;
            }
        </style>

        <div id="relationship_info" style="display: none;">


            <input type="button" class="btn" value="增加關係人" OnClick="add_relationship();">



            <?php $i = 0; ?>
            <form  id="relationship_info_form" >

                <input type="hidden" name="ref_client_verify_code" value="<?= $ref_client_verify_code; ?>">

                <table id="contact_count" style="margin: 10px;">

                    <tr id="w1">
                        <th style="width:65px;" id="w3" class="must_write">客戶姓名</th>
                        <td>
                            <input type="text" style="width:138px;"  name="relation[<?= $i ?>][name]" id="c_name" style="vertical-align:middle;">

                        </td>

                        <th style="width:65px;" id="w3">英文姓名</th>
                        <td>
                            <input type="text" id="recommended" name="relation[<?= $i ?>][english_name]" >
                        </td>

                        <th style="width:65px;" id="sex" id="w3">性別</th>
                        <td colspan="3">
                            男
                            <input type="radio" name="relation[<?= $i ?>][sex]" value="1" checked="true">
                            女
                            <input type="radio" name="relation[<?= $i ?>][sex]" value='0'>
                        </td>
                    </tr>


                    <tr id="w2">
                        <th style="width:65px;" id="w2">行動電話</th>
                        <td>
                            <input type="text" name="relation[<?= $i ?>][mobile]" >
                        </td>

                        <th style="width:65px;" id="w2">住家電話</th>
                        <td>
                            <input type="text" name="relation[<?= $i ?>][home_phone]" >
                        </td>

                        <th style="width:65px;" id="w2">公司電話</th>
                        <td>
                            <input type="text" name="relation[<?= $i ?>][company_phone]" >
                        </td>

                        <th style="width:65px;" id="w2">傳真</th>
                        <td>
                            <input type="text" name="relation[<?= $i ?>][fax]" >
                        </td>
                    </tr>    

                    <tr id="w1">                            
                        <th style="width:65px;" id="w3">住家地址</th>
                        <td colspan="3">
                            <input type="text" style="width:300px;"  name="relation[<?= $i ?>][home_address]" id="relation_home_address_<?= $i ?>" onClick="show_address('relation_home_address_<?= $i ?>')" >
                        </td>

                        <th style="width:65px;" id="w3">公司地址</th>
                        <td colspan="3">
                            <input type="text" style="width:300px;" name="relation[<?= $i ?>][company_address]" id="relation_company_address_<?= $i ?>" onClick="show_address('relation_company_address_<?= $i ?>')" >
                        </td>
                    </tr>    

                </table>
                <div id="html_relationship">                	
                </div>


            </form>


        </div>	

    </div>


</div>

<table style="margin:0px 0px 0px 957px;">
    <tr>
        <td colspan="5"></td>
        <td >
        </td>

        <td class="last_save">
            <button type="button" value="存檔" class="input_background" id="client_submit_form">
            	存檔
            </button>	
        </td>
        <td  class="last_save">
            <input type="button" id="client_reset"  value="重置" class="input_background"> 
        </td>
    </tr>
</table>

<div style="margin:10px;"></div>

<?=
isset($footer) ? $footer : '' ?>